// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file DdsRecorderStatusTypeObjectSupport.cxx
 * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file
 *
 * This file was generated by the tool fastddsgen.
 */

#include "DdsRecorderStatusTypeObjectSupport.hpp"

#include <mutex>
#include <string>

#include <fastcdr/xcdr/external.hpp>
#include <fastcdr/xcdr/optional.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/dds/xtypes/common.hpp>
#include <fastdds/dds/xtypes/type_representation/ITypeObjectRegistry.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp>

#include "DdsRecorderStatus.hpp"


using namespace eprosima::fastdds::dds::xtypes;

// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_DdsRecorderStatus_type_identifier(
        TypeIdentifierPair& type_ids_DdsRecorderStatus)
{

    ReturnCode_t return_code_DdsRecorderStatus {eprosima::fastdds::dds::RETCODE_OK};
    return_code_DdsRecorderStatus =
        eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
        "DdsRecorderStatus", type_ids_DdsRecorderStatus);
    if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderStatus)
    {
        StructTypeFlag struct_flags_DdsRecorderStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
                false, false);
        QualifiedTypeName type_name_DdsRecorderStatus = "DdsRecorderStatus";
        eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_DdsRecorderStatus;
        eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_DdsRecorderStatus;
        CompleteTypeDetail detail_DdsRecorderStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderStatus, ann_custom_DdsRecorderStatus, type_name_DdsRecorderStatus.to_string());
        CompleteStructHeader header_DdsRecorderStatus;
        header_DdsRecorderStatus = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderStatus);
        CompleteStructMemberSeq member_seq_DdsRecorderStatus;
        {
            TypeIdentifierPair type_ids_previous;
            ReturnCode_t return_code_previous {eprosima::fastdds::dds::RETCODE_OK};
            return_code_previous =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "anonymous_string_unbounded", type_ids_previous);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_previous)
            {
                {
                    SBound bound = 0;
                    StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
                    if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                            TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
                            "anonymous_string_unbounded", type_ids_previous))
                    {
                        EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                            "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
                    }
                }
            }
            StructMemberFlag member_flags_previous = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_previous = 0x00000000;
            bool common_previous_ec {false};
            CommonStructMember common_previous {TypeObjectUtils::build_common_struct_member(member_id_previous, member_flags_previous, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_previous, common_previous_ec))};
            if (!common_previous_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure previous member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_previous = "previous";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_previous;
            ann_custom_DdsRecorderStatus.reset();
            CompleteMemberDetail detail_previous = TypeObjectUtils::build_complete_member_detail(name_previous, member_ann_builtin_previous, ann_custom_DdsRecorderStatus);
            CompleteStructMember member_previous = TypeObjectUtils::build_complete_struct_member(common_previous, detail_previous);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_previous);
        }
        {
            TypeIdentifierPair type_ids_current;
            ReturnCode_t return_code_current {eprosima::fastdds::dds::RETCODE_OK};
            return_code_current =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "anonymous_string_unbounded", type_ids_current);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_current)
            {
                {
                    SBound bound = 0;
                    StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
                    if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                            TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
                            "anonymous_string_unbounded", type_ids_current))
                    {
                        EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                            "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
                    }
                }
            }
            StructMemberFlag member_flags_current = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_current = 0x00000001;
            bool common_current_ec {false};
            CommonStructMember common_current {TypeObjectUtils::build_common_struct_member(member_id_current, member_flags_current, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_current, common_current_ec))};
            if (!common_current_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure current member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_current = "current";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_current;
            ann_custom_DdsRecorderStatus.reset();
            CompleteMemberDetail detail_current = TypeObjectUtils::build_complete_member_detail(name_current, member_ann_builtin_current, ann_custom_DdsRecorderStatus);
            CompleteStructMember member_current = TypeObjectUtils::build_complete_struct_member(common_current, detail_current);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_current);
        }
        {
            TypeIdentifierPair type_ids_info;
            ReturnCode_t return_code_info {eprosima::fastdds::dds::RETCODE_OK};
            return_code_info =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "anonymous_string_unbounded", type_ids_info);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_info)
            {
                {
                    SBound bound = 0;
                    StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
                    if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                            TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
                            "anonymous_string_unbounded", type_ids_info))
                    {
                        EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                            "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
                    }
                }
            }
            StructMemberFlag member_flags_info = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
                    false, false, false, false);
            MemberId member_id_info = 0x00000002;
            bool common_info_ec {false};
            CommonStructMember common_info {TypeObjectUtils::build_common_struct_member(member_id_info, member_flags_info, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_info, common_info_ec))};
            if (!common_info_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure info member TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_info = "info";
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_info;
            ann_custom_DdsRecorderStatus.reset();
            CompleteMemberDetail detail_info = TypeObjectUtils::build_complete_member_detail(name_info, member_ann_builtin_info, ann_custom_DdsRecorderStatus);
            CompleteStructMember member_info = TypeObjectUtils::build_complete_struct_member(common_info, detail_info);
            TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_info);
        }
        CompleteStructType struct_type_DdsRecorderStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderStatus, header_DdsRecorderStatus, member_seq_DdsRecorderStatus);
        if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderStatus, type_name_DdsRecorderStatus.to_string(), type_ids_DdsRecorderStatus))
        {
            EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                    "DdsRecorderStatus already registered in TypeObjectRegistry for a different type.");
        }
    }
}

